package leecode

func hasCycle(head *ListNode) bool {
	hashMap := make(map[*ListNode]int)
	for head != nil {
		if _, ok := hashMap[head]; ok {
			return true
		}
		hashMap[head] = head.Val
		head = head.Next
	}
	return false
}
